﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for CarDriverDemeritPointsDB
/// </summary>
/// 
namespace CE.CarInsurance
{
    public class CarDriverDemeritPointsDB
    {
        public CarDriverDemeritPointsDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public Int64 Insert(CarDriverDemeritPoints cardriverdemeritpoints)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocCarDriverDemeritPointsInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@CarDriverDemeritId", cardriverdemeritpoints.CarDriverDemeritId);
            _sPara.Add("@CECarID", cardriverdemeritpoints.CECarID);
            _sPara.Add("@CECarMoreDetailId", cardriverdemeritpoints.CECarMoreDetailId);
            _sPara.Add("@ProviderCompanyId", cardriverdemeritpoints.ProviderCompanyId);
            _sPara.Add("@DriverName", cardriverdemeritpoints.DriverName);
            _sPara.Add("@TotalDemeritPoints", cardriverdemeritpoints.TotalDemeritPoints);
            _sPara.Add("@DemeritDate", cardriverdemeritpoints.DemeritDate);
            _sPara.Add("@TypeofOffence", cardriverdemeritpoints.TypeofOffence);
            _sPara.Add("@RefCEUserId", cardriverdemeritpoints.RefCEUserId);
            _sPara.Add("@ViewedDetailId", cardriverdemeritpoints.ViewedDetailId);
            _sPara.Add("@Status", cardriverdemeritpoints.Status);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataSet GetCarDriverDemeritPoints(Int64 CarId, Int64 CarMoreId, Int64 CEId, Int64 ProviderCompanyId)
        {
            DataSet _demeritpoints = null;
            MyDatabase _db = new MyDatabase();
            string _spName = "sprocCarDriverDemeritPointsSelectSingleItem";

            SortedList _spara = new SortedList();
            _spara.Add("@CECarId", CarId);
            _spara.Add("@CECarMoreDetailId", CarMoreId);
            _spara.Add("@RefCEUserId", CEId);
            _spara.Add("@ProviderCompanyId", ProviderCompanyId);

            using (DataSet _ds = _db.GetDataSet(_spName, _spara))
            {
                if (_ds != null && _ds.Tables[0].Rows.Count > 0)
                {
                    _demeritpoints = _ds;
                }
            }
            return _demeritpoints;
        }

        public bool Update()
        {
            return true;
        }

        public bool Delete()
        {
            return true;
        }

        public void DeleteCarDriverDemeritPoints(Int64 CarId, Int64 CarMoreId, Int64 CEId)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocCarDriverDemeritPointsDeleteItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@CECarId", CarId);
            _sPara.Add("@CECarMoreDetailId", CarMoreId);
            _sPara.Add("@RefCEUserId", CEId);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            //return _result;
        }

        #region "remove"
        
        //public Int64 InsertEtiqa(CarDriverDemeritPoints cardriverdemeritpoints)
        //{
        //    MyDatabase _db = new MyDatabase();
        //    Int64 _result = -1;
        //    string _spName = "sprocCarDriverDemeritPointsInsertUpdateSingleItemEtiqa";

        //    SortedList _sPara = new SortedList();

        //    #region Parameter
        //    _sPara.Add("@CarDriverDemeritId", cardriverdemeritpoints.CarDriverDemeritId);
        //    _sPara.Add("@CECarID", cardriverdemeritpoints.CECarID);
        //    _sPara.Add("@CECarMoreDetailId", cardriverdemeritpoints.CECarMoreDetailId);
        //    _sPara.Add("@ProviderCompanyId", cardriverdemeritpoints.ProviderCompanyId);
        //    _sPara.Add("@DriverName", cardriverdemeritpoints.DriverName);
        //    _sPara.Add("@TotalDemeritPoints", cardriverdemeritpoints.TotalDemeritPoints);
        //    _sPara.Add("@RefCEUserId", cardriverdemeritpoints.RefCEUserId);
        //    _sPara.Add("@ViewedDetailId", cardriverdemeritpoints.ViewedDetailId);
        //    _sPara.Add("@Status", cardriverdemeritpoints.Status);
        //    #endregion

        //    _result = _db.ExecuteSP(_spName, _sPara);

        //    return _result;
        //}

        //public DataSet GetCarDriverDemeritPointsEtiqa(Int64 CarId, Int64 CarMoreId, Int64 CEId, Int64 ProviderCompanyId)
        //{
        //    DataSet _demeritpoints = null;
        //    MyDatabase _db = new MyDatabase();
        //    string _spName = "sprocCarDriverDemeritPointsSelectSingleItemEtiqa";

        //    SortedList _spara = new SortedList();
        //    _spara.Add("@CECarId", CarId);
        //    _spara.Add("@CECarMoreDetailId", CarMoreId);
        //    _spara.Add("@RefCEUserId", CEId);
        //    _spara.Add("@ProviderCompanyId", ProviderCompanyId);

        //    using (DataSet _ds = _db.GetDataSet(_spName, _spara))
        //    {
        //        if (_ds != null && _ds.Tables[0].Rows.Count > 0)
        //        {
        //            _demeritpoints = _ds;
        //        }
        //    }
        //    return _demeritpoints;
        //}



        //public Int64 InsertRsa(CarDriverDemeritPoints cardriverdemeritpoints)
        //{
        //    MyDatabase _db = new MyDatabase();
        //    Int64 _result = -1;
        //    string _spName = "sprocCarDriverDemeritPointsInsertUpdateSingleItemRsa";

        //    SortedList _sPara = new SortedList();

        //    #region Parameter
        //    _sPara.Add("@CarDriverDemeritId", cardriverdemeritpoints.CarDriverDemeritId);
        //    _sPara.Add("@CECarID", cardriverdemeritpoints.CECarID);
        //    _sPara.Add("@CECarMoreDetailId", cardriverdemeritpoints.CECarMoreDetailId);
        //    _sPara.Add("@ProviderCompanyId", cardriverdemeritpoints.ProviderCompanyId);
        //    _sPara.Add("@DriverName", cardriverdemeritpoints.DriverName);
        //    _sPara.Add("@TotalDemeritPoints", cardriverdemeritpoints.TotalDemeritPoints);
        //    _sPara.Add("@DemeritDate", cardriverdemeritpoints.DemeritDate);
        //    _sPara.Add("@TypeofOffence", cardriverdemeritpoints.TypeofOffence);
        //    _sPara.Add("@RefCEUserId", cardriverdemeritpoints.RefCEUserId);
        //    _sPara.Add("@ViewedDetailId", cardriverdemeritpoints.ViewedDetailId);
        //    _sPara.Add("@Status", cardriverdemeritpoints.Status);
        //    #endregion

        //    _result = _db.ExecuteSP(_spName, _sPara);

        //    return _result;
        //}

        //public DataSet GetCarDriverDemeritPointsRsa(Int64 CarId, Int64 CarMoreId, Int64 CEId, Int64 ProviderCompanyId)
        //{
        //    DataSet _demeritpoints = null;
        //    MyDatabase _db = new MyDatabase();
        //    string _spName = "sprocCarDriverDemeritPointsSelectSingleItemRsa";

        //    SortedList _spara = new SortedList();
        //    _spara.Add("@CECarId", CarId);
        //    _spara.Add("@CECarMoreDetailId", CarMoreId);
        //    _spara.Add("@RefCEUserId", CEId);
        //    _spara.Add("@ProviderCompanyId", ProviderCompanyId);

        //    using (DataSet _ds = _db.GetDataSet(_spName, _spara))
        //    {
        //        if (_ds != null && _ds.Tables[0].Rows.Count > 0)
        //        {
        //            _demeritpoints = _ds;
        //        }
        //    }
        //    return _demeritpoints;
        //}
        
        #endregion
    }
}